home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.lang.c++
- Subject: Re: [Q] Why doesn't this compile?
- Date: 18 Apr 1996 16:19:39 GMT
- Organization: Borland International
- Message-ID: <4l5q2r$ktd@druid.borland.com>
- References: <317523C0.5042@eps.agfa.be> <4l3cpv$l74@helium.einet.net>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4l3cpv$l74@helium.einet.net>, arisco@tradewave.com says...
- >
- >Ranko Orlic <rorlic@eps.agfa.be> wrote:
- >
- >>Using MSVC 4.0 compiler I get the following:
- >
- >>File test.cpp: ---------------------------------
- >
- >>class A {
- >>public:
- >> class L {
- >> public:
- >> L() {}
- >> virtual void f() {
- >> int dummy = 0;
- >> }
- >> };
- >> A();
- >>};
- >
- >>class B : public A {
- >> class L : public A::L {
- >> public:
- >> L() {}
- >> virtual void f() {
- >> A::L::f();
- >> }
- >> };
- >> B();
- >>};
- >
- >>Compilation result: ----------------------------
- >
- >>test.cpp(18) : error C2352: 'A::L::f' : illegal call of
- >>nonstatic member function
- >>Error executing cl.exe.
- >>test.obj - 1 error(s), 1 warning(s)
- >
- >>------------------------------------------------
- >
- >>Anybody knows what's wrong with it?
- >>Thanks,
- >
- >>-- Ranko.
- >
- >You cannot call a non-static member function without specifying
- >an object. The way you've written this, there is no way for B::L::f()
- >to set its "this" pointer. Of course, if this is really what you want
- >
- >to do, the declaration of B::L::f() is unnecessary, since B::L
- > inherits the A::L::f() virtual method from its base class.
-
- Huh? The call is perfectly legal, and the scope qualifier is necessary. The
- nesting makes things look more complicated, but this is nothimg more than a
- virtual function calling the corresponding function in the base class. The name
- of that base class is A::L, which is why things look a little nasty.
-
-